package o;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.forum.posts.api.IPostDetailProtocol;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import o.bzd.b;
import o.bzd.e;
import o.bzd.h;

public class bzv implements dsb {
    private ImageView ˊ;
    private LinearLayout ˋ;
    private Drawable ˎ;
    private TextView ˏ;
    private bzh ॱ;

    public void ॱ(bzh o_bzh) {
        this.ॱ = o_bzh;
    }

    public View ˎ(final Context context) {
        if (this.ॱ == null || this.ॱ.ˋ() == null) {
            return null;
        }
        String ˎ;
        this.ˋ = (LinearLayout) LayoutInflater.from(context).inflate(h.ॱˎ, null);
        this.ˏ = (TextView) this.ˋ.findViewById(b.ˌॱ);
        this.ˊ = (ImageView) this.ˋ.findViewById(b.ˊʽ);
        this.ˎ = epo.ॱ(context.getResources().getDrawable(e.ˊॱ), -1);
        CharSequence charSequence = "";
        if (this.ॱ.ˋ() != null) {
            charSequence = this.ॱ.ˋ().ˏ();
            ˎ = this.ॱ.ˋ().ˎ();
        } else {
            ˎ = "";
        }
        if (dof.ॱ(charSequence)) {
            this.ˏ.setText("");
        } else {
            this.ˏ.setText(charSequence);
        }
        this.ˏ.setImportantForAccessibility(2);
        ˊ();
        this.ˋ.setOnClickListener(new evx(this) {
            final /* synthetic */ bzv ˋ;

            public void ˋ(View view) {
                fjb ˎ = fho.ˏ().ˋ("Posts").ˎ("post.detail.activity");
                IPostDetailProtocol iPostDetailProtocol = (IPostDetailProtocol) ˎ.ˊ();
                iPostDetailProtocol.setUri(ˎ);
                iPostDetailProtocol.setPositionToCommentCard(true);
                iPostDetailProtocol.setSourceType(1);
                fiu.ˊ().ˏ(context, ˎ);
            }
        });
        return this.ˋ;
    }

    private void ˊ() {
        if (!dof.ॱ(this.ॱ.ˊ()) && !dof.ॱ(this.ॱ.ˏ())) {
            CSSRule rule = new CSSSelector(this.ॱ.ˏ()).getRule(CSSStyleSheet.parse(this.ॱ.ˊ()).getRootRule());
            if (rule != null) {
                CSSRule rule2 = new CSSSelector(".widget").getRule(rule);
                if (rule2 != null) {
                    CSSView.wrap(this.ˊ, rule2).render(false);
                }
                rule2 = new CSSSelector(".title").getRule(rule);
                if (rule2 != null) {
                    CSSView.wrap(this.ˏ, rule2).render(false);
                }
                ˎ(ˋ(rule, ".download-button", CSSPropertyName.FONT_COLOR, true), ˋ(rule, ".download-button", CSSPropertyName.FONT_COLOR, false));
            }
        }
    }

    private void ˎ(Drawable drawable, Drawable drawable2) {
        if (drawable != null && drawable2 != null) {
            Drawable stateListDrawable = new StateListDrawable();
            stateListDrawable.addState(new int[]{16842908, 16842919}, drawable2);
            stateListDrawable.addState(new int[]{16842908}, drawable2);
            stateListDrawable.addState(new int[]{16842919}, drawable2);
            stateListDrawable.addState(new int[0], drawable);
            this.ˋ.setBackground(stateListDrawable);
        }
    }

    private Drawable ˋ(CSSRule cSSRule, String str, String str2, boolean z) {
        CSSRule rule = new CSSSelector(str).getRule(cSSRule);
        if (rule == null) {
            return null;
        }
        CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(str2);
        if (propertyValue == null || !(propertyValue instanceof CSSMonoColor)) {
            return null;
        }
        return ˋ(((CSSMonoColor) propertyValue).getColor(), z, 0.8f);
    }

    private Drawable ˋ(int i, boolean z, float f) {
        int i2;
        if (z) {
            i2 = e.ˏॱ;
            i = cgr.ॱ(i, f);
        } else {
            i2 = e.ͺ;
        }
        return epo.ॱ(this.ˋ.getContext().getResources().getDrawable(i2), i);
    }

    public void ˊ(int i) {
        if (this.ˋ != null) {
            ˎ(epo.ॱ(this.ˋ.getContext().getResources().getDrawable(e.ˏॱ), i), epo.ॱ(this.ˋ.getContext().getResources().getDrawable(e.ͺ), i));
        }
        if (!(this.ˊ == null || this.ˎ == null)) {
            this.ˊ.setImageDrawable(epo.ॱ(this.ˎ, i));
        }
        if (this.ˏ != null) {
            this.ˏ.setTextColor(i);
        }
    }
}
